package com.csproj.basic.repository;

import com.csproj.basic.domain.Container;
import com.csproj.basic.domain.Warehouse;
import com.csproj.basic.repository.custom.ContainerRepositoryCustom;
import org.springframework.stereotype.Repository;

import org.springframework.data.jpa.repository.*;

import java.util.List;


/**
 * Spring Data JPA repository for the Container entity.
 */
@SuppressWarnings("unused")
@Repository
public interface ContainerRepository extends JpaRepository<Container, String>, ContainerRepositoryCustom {
    /**
     * 根据ids查询集装箱信息
     * @author LM
     * @date   2018-09-18
     * @param ids
     * @return
     */
    @Query(" from Container where id in (?1) ")
    List<Container> findByIds(String[] ids);


    /**
     * 根据ID删除数据
     * @author LM
     * @date   2018-09-18
     * @param id 机构id
     */
    @Modifying
    @Query("UPDATE Container SET deletedFlag = 1 where id = ?1")
    void delete(String id);

    /**
     * 根据ID删除数据
     * @author LM
     * @date   2018-09-18
     * @param id 机构id
     */
    @Query(" from Container where deletedFlag = 0 and id = ?1")
    Container findById(String id);

    /**
     * findByName
     * @param name
     * @return
     */
    Container findFirstByContainerNoAndDeletedFlagIsFalse(String name);
    /**
     * 根据机构ids，批量删除集装箱信息
     * @param ids
     */
    @Modifying
    @Query(" update Container set deletedFlag = 1 where id in (?1) ")
    void deleteIds(String[] ids);
}
